<template>
  <div class="content">
    <div class="slider">
      <el-carousel arrow="never" height="349px">
        <el-carousel-item v-for="item in sliderList" :key="item">
          <div
            class="slider_img"
            :style="{ 'background-image': 'url(' + item + ')' }"
          ></div>
        </el-carousel-item>
      </el-carousel>
      <div class="banner_nav">
        <div
          class="banner"
          v-for="item in bannerList"
          :key="item.path"
          @click="router.push(item.path)"
        >
          <img :src="item.img" />
          <h3>{{ item.title }}</h3>
        </div>
      </div>
    </div>

    <div class="section">
      <div class="sec_zixun">
        <div class="index_tit">
          健康资讯
          <div class="tit_more mouse_over">
            更多
            <i class="icon4 icons4_more"></i>
          </div>
        </div>
        <div class="sec_news">
          <div class="hd">
            <i class="hd_t"> 健康资讯 </i>
          </div>
          <ul class="list">
            <li
              class="mouse_over"
              v-for="item in homeScience"
              :key="item.title"
            >
              <label>·</label>{{ item.title }}
            </li>
          </ul>
          <div class="hd">
            <i class="hd_t kp_t"> 疾病科普 </i>
          </div>
          <ul class="list">
            <li
              class="mouse_over"
              v-for="item in homeArticle"
              :key="item.title"
            >
              <label>·</label>{{ item.title }}
            </li>
          </ul>
        </div>
      </div>
      <div class="sec_tuijian">
        <div class="index_tit">
          医院推荐
          <div class="tit_more mouse_over">
            更多
            <i class="icon4 icons4_more"></i>
          </div>
        </div>
        <div class="list">
          <el-card
            class="con"
            shadow="hover"
            v-for="item in homeHospital"
            :key="item.hospitalId"
          >
            <img :src="item.img" />
            <p>{{ item.name }}</p>
            <div class="btn">快速挂号</div>
          </el-card>
        </div>
      </div>
    </div>

    <div class="section">
      <div class="sec_tijian">
        <div class="index_tit">体检中心</div>
        <div class="tijian_con">
          <div class="con_left">
            <div class="left_top border5">
              <p><label>常规防癌套餐</label></p>
              <p>关爱女性,呵护健康</p>
              <p>￥<span>688</span> 起</p>
            </div>
            <div class="left_bottom">
              <div class="pre border5">
                <p><label>糖尿病常规体检套餐</label></p>
                <p>健康男人，定期体检</p>
                <p>￥<span>299</span> 起</p>
              </div>
              <div class="pre pre2 border5">
                <p><label>女性体检套餐</label></p>
                <p>入职体检</p>
                <p>￥<span>698</span> 起</p>
              </div>
            </div>
          </div>

          <div class="con_right border5">
            <div class="index_tit">
              特惠套餐
              <div class="tit_more mouse_over">
                更多
                <i class="icon4 icons4_more"></i>
              </div>
            </div>
            <ul class="list">
              <li class="mouse_over">常规防癌套餐（男性）</li>
              <li class="mouse_over">常规防癌套餐（男性）</li>
            </ul>
            <div class="index_tit" style="border-top: 1px dashed #eee">
              体检机构
              <div class="tit_more mouse_over">
                更多
                <i class="icon4 icons4_more"></i>
              </div>
            </div>
            <ul class="list">
              <li class="mouse_over">中山大学孙逸仙纪念医院</li>
              <li class="mouse_over">中山大学孙逸仙纪念医院</li>
            </ul>
          </div>
        </div>
      </div>
      <div class="sec_wenzhen">
        <div class="index_tit">
          在线问诊
          <div class="tit_more mouse_over">
            更多
            <i class="icon4 icons4_more"></i>
          </div>
        </div>
        <ul class="wenzhen_con border5">
          <li v-for="item in 4">
            <div>
              <img :src="wenzhen_con" />
            </div>
            <div class="con">
              <p>朱丽华 <span>主任医师</span></p>
              <p>暨南大学附属第一医院</p>
              <div class="btn">咨询医生</div>
            </div>
          </li>
        </ul>
      </div>
    </div>
    <div class="section" style="height: 650px">
      <div class="sec_wenda">
        <div class="index_tit">
          健康问答
          <div class="dept">
            <span
              v-for="item in deptClsList"
              :key="item.name"
              :class="{
                activeDept: activeDept == item.deptClsId,
              }"
              @click="changeDept(item)"
              >{{ item.name }}</span
            >
          </div>
        </div>
        <div class="wenda_con">
          <div class="con" v-for="item in 4">
            <img :src="wenzhen_con" />
            <div class="info">
              <p><span> 权卫</span>副主任医师</p>
              <p>南昌大学第四附属医院</p>
              <p>擅长：擅长眼底病的诊断和治疗</p>
            </div>
            <div class="ques">
              <div class="q"><label>问</label>视神经萎缩主要治疗哪方面</div>
              <div class="a">
                <label>答</label
                >视神经萎缩主要治疗原发疾病，还要给予扩血管药、营养神经的药物治疗，比如复方血栓通胶囊，甲钴胺片，胞磷胆碱钠片。视神经萎缩，是指任何病因引起的视网膜神经节细胞及其轴索发生的病变，一般发生于视网膜至外侧膝
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="sec_zidoc">
        <div class="index_tit">
          咨询医生
          <div class="tit_more mouse_over">
            更多
            <i class="icon4 icons4_more"></i>
          </div>
        </div>
        <ul class="zidoc_con border5">
          <li v-for="item in 3">
            <div class="info">
              <img :src="wenzhen_con" />
              <div>
                <p><span> 杨越</span>副主任医师</p>
                <p>深圳市宝安区中医院</p>
              </div>
            </div>
            <div class="goods">
              擅长：擅长用中西医结合方法治疗肝病和内科常见病，有16年大内科住院部工作经验。
            </div>
            <div class="btn mouse_over2">咨询医生</div>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { useRouter, useRoute } from "vue-router";
import { computed, onMounted, reactive, ref, watch } from "vue";
import { useStore } from "vuex";
import { ElMessage } from "element-plus";
import { CODE } from "@/utils/StatusCode";
import { Hospital, ScienceArticle, DeptCls } from "@/types/entity";
import { showHospital, showScienceArticle, getDeptCls } from "@/api/home";

const router = useRouter();
const route = useRoute();

onMounted(() => {
  getData();
});

function getData() {
  getHomeHospital();
  getHomeScience();
  getHomeArticle();
  getDeptClsList();
}
const sliderList = [require("../assets/image/index-ban.png")];
const bannerList = [
  {
    img: require("../assets/picture/ico-bnav1.png"),
    title: "问医生",
    path: "/doctor",
  },
  {
    img: require("../assets/picture/ico-bnav2.png"),
    title: "挂号",
    path: "/hospital",
  },
];
const wenzhen_con = require("../assets/picture/84AD989607734CE8AC8597DEC1AA98FA_290x200.jpg");

/**
 * 查询首页医院推荐
 */
const homeHospital = ref<Hospital[]>([]);
async function getHomeHospital() {
  const res = await showHospital({ count: 6 });
  if (res.code == CODE.OK) {
    homeHospital.value = res.data;
  }
}
/**
 * 查询首页健康资讯
 */
const homeScience = ref<ScienceArticle[]>([]);
async function getHomeScience() {
  const res = await showScienceArticle({ count: 6, type: 2 });
  if (res.code == CODE.OK) {
    homeScience.value = res.data;
  }
}
/**
 * 查询首页疾病科普
 */
const homeArticle = ref<ScienceArticle[]>([]);
async function getHomeArticle() {
  const res = await showScienceArticle({ count: 6, type: 1 });
  if (res.code == CODE.OK) {
    homeArticle.value = res.data;
  }
}
/**
 * 查询科室分类列表
 */
const deptClsList = ref<DeptCls[]>([]);
const activeDept = ref();

async function getDeptClsList() {
  const res = await getDeptCls({ count: 8, type: null });
  if (res.code == CODE.OK) {
    deptClsList.value = res.data;
    changeDept(deptClsList.value[0]);
  }
}
function changeDept(item: DeptCls) {
  activeDept.value = item.deptClsId;
  getWendaList(activeDept.value);
}
function getWendaList(deptClsId: number) {}
</script>
<style lang="less" scoped>
.content {
  width: 100%;
  padding-bottom: 20px;
}
.border5 {
  border: 1px solid #eee;
  border-radius: 5px;
}
.list {
  margin-top: 8px;
  font-size: 14px;
  li {
    padding: 0 28px;
    margin-bottom: 15px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: #666;
    &:hover {
      color: #2acf8d;
    }
    label {
      font-weight: bold;
      margin-right: 12px;
      font-size: 14px;
    }
  }
}
.slider {
  width: 1012px;
  height: 350px;
  margin-left: 188px;
  position: relative;
  .slider_img {
    width: 100%;
    height: 100%;
    background-size: auto 100%;
    background-position: center center;
    background-repeat: no-repeat;
    cursor: pointer;
  }
  .banner_nav {
    position: absolute;
    right: 10px;
    top: 10px;
    z-index: 999;
    .banner {
      width: 180px;
      height: 150px;
      background-color: #fff;
      border-radius: 4%;
      margin-bottom: 10px;
      cursor: pointer;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
      &:hover {
        opacity: 0.8;
      }
      img {
        width: 60px;
        height: 60px;
      }
    }
  }
}
.section {
  width: 100%;
  background-color: #fff;
  height: 660px;
  margin-top: 20px;
  display: flex;
  border-radius: 5px;
  .sec_zixun {
    width: 412px;
    height: 100%;
    border-right: 1px solid #eee;
    .sec_news {
      width: 100%;
      .hd {
        padding: 10px 36px;
        .hd_t {
          display: inline-block;
          height: 22px;
          line-height: 22px;
          font-size: 10px;
          padding: 0 4px;
          min-width: 44px;
          text-align: center;
          background-color: #2acf8d;
          border-radius: 3px;
          color: #fff;
        }
        .kp_t {
          background-color: #ff8100;
        }
      }
    }
  }
  .sec_tuijian {
    width: 787px;
    .list {
      padding: 0 29px;
      display: grid;
      justify-content: space-between;
      grid-template-columns: repeat(auto-fill, 230px);
      grid-gap: 15px;
      .con {
        width: 230px;
        height: 260px;
        :deep(.el-card__body) {
          padding: 15px;
        }
        img {
          width: 198px;
          height: 140px;
          cursor: pointer;
        }
        p {
          font-size: 14px;
          color: #4b5566;
          margin-top: 16px;
          text-align: center;
        }
        .btn {
          width: 78px;
          height: 30px;
          line-height: 30px;
          border: 1px solid #2acf8d;
          border-radius: 20px;
          text-align: center;
          font-size: 14px;
          color: #2acf8d;
          margin: 20px auto 0 auto;
          background-color: #fff;
          transition: all 0.3s ease;
          cursor: pointer;
          &:hover {
            color: #fff;
            background-color: #2acf8d;
          }
        }
      }
    }
  }
  .sec_tijian {
    width: 810px;
    height: 100%;
    .tijian_con {
      width: 100%;
      margin-left: 32px;
      display: flex;
      .con_left {
        width: 476px;
        .left_top {
          width: 100%;
          height: 240px;
          background-image: url(../assets/image/index_tj1.jpg);
          padding-top: 54px;
          padding-left: 22px;
          box-sizing: border-box;
          font-size: 14px;
          &:hover {
            opacity: 0.8;
            cursor: pointer;
          }
          > p:nth-child(1) {
            font-size: 30px;
            label {
              line-height: 42px;
              background: url(../assets/image/tj-hbg2.png) center bottom
                repeat-x;
            }
          }
          > p:nth-child(2) {
            margin-top: 16px;
            color: #999999;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
          > p:nth-child(3) {
            color: #2acf8d;
            font-weight: bold;
            margin-top: 65px;
            span {
              font-weight: 700;
              font-size: 30px;
            }
          }
        }
        .left_bottom {
          padding-top: 20px;
          display: flex;
          justify-content: space-between;
          .pre {
            width: 228px;
            height: 290px;
            background-image: url(../assets/image/index_tj2.jpg);
            padding-top: 34px;
            padding-left: 22px;
            box-sizing: border-box;
            font-size: 14px;
            &:hover {
              opacity: 0.8;
              cursor: pointer;
            }
            > p:nth-child(1) {
              font-size: 24px;
              label {
                line-height: 30px;
                background: url(../assets/image/tj-hbg1.png) center bottom
                  repeat-x;
              }
            }
            > p:nth-child(2) {
              margin-top: 16px;
              color: #999999;
              text-overflow: ellipsis;
              white-space: nowrap;
            }
            > p:nth-child(3) {
              color: #ff8100;
              font-weight: bold;
              margin-top: 60px;
              span {
                font-weight: 700;
                font-size: 30px;
              }
            }
          }
          .pre2 {
            background-image: url(../assets/image/index_tj3.jpg);
          }
        }
      }
      .con_right {
        width: 284px;
        height: 550px;
        margin-left: 20px;
        .index_tit {
          padding: 10px 20px;
          font-size: 16px;
        }
        .list {
          li {
            padding: 0 20px;
          }
        }
      }
    }
  }
  .sec_wenzhen {
    flex: 1;
    height: 100%;
    margin: 0 30px 0 20px;
    .index_tit {
      padding-left: 0;
    }
    .wenzhen_con {
      width: 100%;
      height: 550px;
      overflow: auto;
      li {
        padding: 12px 26px;
        display: flex;
        img {
          width: 60px;
          height: 60px;
          border-radius: 50%;
          vertical-align: middle;
        }
        .con {
          margin-left: 23px;
          > p:nth-child(1) {
            font-size: 18px;
            font-weight: bold;
            margin-right: 12px;
            span {
              font-size: 14px;
              color: #999;
              margin-left: 4px;
            }
          }
          > p:nth-child(2) {
            font-size: 14px;
            color: #666666;
            margin: 8px 0;
          }
          .btn {
            width: 78px;
            height: 30px;
            line-height: 30px;
            border-radius: 20px;
            text-align: center;
            font-size: 12px;
            color: #fff;
            background-color: #2acf8d;
            cursor: pointer;
          }
        }
      }
    }
  }
  .sec_wenda {
    width: 810px;
    height: 100%;
    .dept {
      margin-left: 10px;
      display: inline-block;
      > span {
        display: inline-block;
        height: 28px;
        line-height: 28px;
        padding: 0 12px;
        font-size: 14px;
        color: #333;
        border: 1px solid #e1e1e1;
        border-radius: 3px;
        font-weight: normal;
        margin-left: 10px;
        cursor: pointer;
      }
      .activeDept {
        background-color: #2acf8d;
        color: #fff;
      }
    }
    .wenda_con {
      .con {
        padding: 26px 26px;
        height: 85px;
        display: flex;
        align-items: center;
        width: 760px;
        justify-content: space-between;
        border-bottom: 1px solid #e1e1e1;
        margin-left: 6px;
        img {
          width: 60px;
          height: 60px;
          border-radius: 50%;
          vertical-align: middle;
        }
        .info {
          height: 100%;
          width: 200px;
          font-size: 14px;
          > p:nth-child(1) {
            color: #999;
            font-weight: normal;
            margin-bottom: 6px;
            span {
              font-size: 18px;
              color: #333;
              font-weight: bold;
              margin-right: 8px;
            }
          }
          > p:nth-child(2) {
            max-width: 100%;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
          }
          > p:nth-child(3) {
            color: #999;
            line-height: 18px;
            max-height: 36px;
            margin-top: 8px;
            overflow: hidden;
            display: -webkit-box;
            text-overflow: ellipsis;
            padding-right: 20px;
          }
        }
        .ques {
          height: 100%;
          width: 482px;
          cursor: pointer;
          div {
            padding-left: 42px;
            position: relative;
          }
          label {
            display: block;
            width: 30px;
            height: 30px;
            line-height: 30px;
            border-radius: 50%;
            font-size: 14px;
            position: absolute;
            left: 0;
            top: 50%;
            margin-top: -15px;
            text-align: center;
          }
          .q {
            font-size: 16px;
            color: #333;
            font-weight: bold;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            margin-bottom: 10px;
            label {
              background-color: #e9faf3;
              color: #2acf8d;
              font-weight: bold;
            }
          }
          .a {
            font-size: 14px;
            color: #999;
            line-height: 24px;
            max-height: 48px;
            overflow: hidden;
            display: -webkit-box;
            text-overflow: ellipsis;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            min-height: 30px;
            label {
              background-color: #fff2e5;
              color: #ff8100;
            }
          }
        }
      }
    }
  }
  .sec_zidoc {
    flex: 1;
    height: 100%;
    margin: 0 30px 0 20px;
    .index_tit {
      padding-left: 0;
    }
    .zidoc_con {
      width: 100%;
      height: 550px;
      overflow: auto;
      font-size: 14px;
      li {
        margin-top: 12px;
        .info {
          display: flex;
          padding: 12px 26px;
          img {
            width: 60px;
            height: 60px;
            border-radius: 50%;
          }
          div {
            padding-left: 23px;
            color: #666;
            display: flex;
            flex-direction: column;
            justify-content: space-evenly;
            > p:nth-child(1) {
              color: #999;
              font-weight: normal;
              span {
                font-size: 18px;
                color: #333;
                font-weight: bold;
                margin-right: 12px;
              }
            }

            > p:nth-child(2) {
              max-width: 100%;
              overflow: hidden;
              white-space: nowrap;
              text-overflow: ellipsis;
            }
          }
        }
        .goods {
          padding: 0 26px;
          color: #999;
          line-height: 18px;
          max-height: 36px;
          overflow: hidden;
          display: -webkit-box;
          text-overflow: ellipsis;
        }
        .btn {
          text-align: center;
          width: 140px;
          height: 28px;
          line-height: 28px;
          text-align: center;
          background-color: #2acf8d;
          font-size: 12px;
          color: #fff;
          border-radius: 20px;
          margin: 0 auto;
          margin-top: 15px;
        }
      }
    }
  }
}
</style>
